﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Ymatou.ServiceCenter;

namespace WebApiDemo.Contract
{
    [Resource("webapi.ymatou.com", "api/Default/TestPostJson", Method.POST, ParameterBuildType.Json)]
    public class TestPostJsonRequest:IValidate
    {
        public string Id { get; set; }

        public string Name { get; set; }

        public int Age { get; set; }

        public decimal Price { get; set; }
        public void Validate()
        {
            if(string.IsNullOrWhiteSpace(this.Id))
                throw new ArgumentNullException("Id");

            if(string.IsNullOrWhiteSpace(this.Name))
                throw new ArgumentNullException("Name");

            if(this.Age<0)
                throw new ArgumentException("Age值不能小于0", "Age");

            if(this.Price<0)
                throw new ArgumentException("Price值不能小于0", "Price");
        }
    }

    public class TestPostJsonResponse
    {
        public string Id { get; set; }

        public string Data { get; set; }
    }
}
